package com.sky.service.impl;

import com.alibaba.fastjson.JSON;
import com.sky.utils.HttpClientUtil;
import com.sky.vo.RankingResponse;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.util.HashMap;

@Service
public class RankingServiceImpl {
    private static final String FLASK_API_BASE_URL = "http://localhost:5000/api/rankings";

    /**
     * 获取排行榜数据
     * @param type
     * @return
     */
    public RankingResponse getRankingList(String type) {
        // 构建请求URL
        HashMap<String, String> map = new HashMap<>();
        map.put("type", type);
        String json = HttpClientUtil.doGet(FLASK_API_BASE_URL,map);
        return JSON.parseObject(json, RankingResponse.class);
    }
}
